Imports NENAData.NENAMember

Partial Class Home
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    'Protected WithEvents lbl1 As System.Web.UI.WebControls.Label

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim oNenaData As NENAMember = New NENAMember
        Dim oMember = oNenaData.GetMember_byCsUserName(User.Identity.Name)
        Try
            Session("Member_ID") = oMember.Member_ID
            Session("FullName") = oMember.FirstName & " " & oMember.LastName

            Response.Write("NENA MemberID :" & Session("Member_ID"))
        Catch ex As Exception
            'memberid may not be assigned
            Session.Abandon()
            Response.Redirect("http://membership.nena.ca/", False)
        End Try

        Dim x As New NENAData.NENAMember.TcXml()
        Dim oRoles As List(Of TelligentCommunity.Roles)
        oRoles = x.GetUserRoles(oMember.CS_UserID)
        Session("Roles") = oRoles

        EnableFormPanels(oRoles)
        AddPanels(oRoles)
    End Sub
    Private Sub EnableFormPanels(oRoles As List(Of TelligentCommunity.Roles))

        If oRoles.Contains(TelligentCommunity.Roles.MembershipViewAll) Then
            panelENABC_Membership.Visible = True
            panelEDNA_Membership.Visible = True
            panelENAO_Membership.Visible = True
            panelENIG_Membership.Visible = True
            panelIndependant_Membership.Visible = True
            panelInternational_Membership.Visible = True
            panelNBENA_Membership.Visible = True
            panelNLENA_Membership.Visible = True
            panelNSENA_Membership.Visible = True
            panelPEIENA_Membership.Visible = True
            panelSENG_Membership.Visible = True
        End If

    End Sub
    Private Sub AddPanels(oRoles As List(Of TelligentCommunity.Roles))

        If oRoles.Contains(TelligentCommunity.Roles.MembershipAdministrator) Then
            panelAdmin.Visible = True
            'panelCommitees.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.ENABC_Membership) Then
            panelENABC_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.ENIG_Membership) Then
            panelENIG_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.SENG_Membership) Then
            panelSENG_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.EDNA_Membership) Then
            panelEDNA_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.ENAO_Membership) Then
            panelENAO_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.NBENA_Membership) Then
            panelNBENA_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.NSENA_Membership) Then
            panelNSENA_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.NLENA_Membership) Then
            panelNLENA_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.PEIENA_Membership) Then
            panelPEIENA_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.International_Membership) Then
            panelInternational_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.Independant_Membership) Then
            panelIndependant_Membership.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.NCAC_Executive) Then
            panelNCAC_Executive.Visible = True
        End If
        If oRoles.Contains(TelligentCommunity.Roles.ConferenceCommittee) Then
            panelConferenceCommittee.Visible = True
        End If
    End Sub

    Protected Sub DisplayBrowserInfo()
        Dim oRoles As List(Of TelligentCommunity.Roles) = Session("Roles")

        Response.Write("<br />You are a member of: ")
        For Each role In oRoles
            Response.Write("<br /> " & role.ToString())
        Next

    End Sub
End Class
